package com.chinasofti.collection;

public class Demo03 {
    public static void main(String[] args) {
        int sum = getSum(100);
        System.out.println("sum = " + sum);
    }

    public static int  getSum(int i){
        //1- 100
        //100 + (99 - 1)
        //99+(98 - 1)
        // ...
        //1
        if(i == 1){
            return 1;
        }else{
            return i + getSum(i - 1);
        }
    }
}
